//
//  LGRecommendDoctorCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/24.
//

#import "LGRecomendDoctorCell.h"

@interface LGRecomendDoctorCell() 
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIImageView *headPic;
/**   */
@property (nonatomic , strong)UILabel *docNameLabel;
/**   */
@property (nonatomic , strong)UILabel *postTitleLabel;
/**   */
@property (nonatomic , strong)UILabel *hospitalLabel;
/**   */
@property (nonatomic , strong)UIView *bottomView;
/**   */
@property (nonatomic , strong)UIImageView *iconView;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;
/**   */
@property (nonatomic , strong)UILabel *descLabel;
@end

@implementation LGRecomendDoctorCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    [self.headPic sd_setImageWithURL:[NSURL URLWithString:dataDic[@"avatar_url"]]];
    self.docNameLabel.text = dataDic[@"realname"];
    self.postTitleLabel.text = dataDic[@"profess"];
    self.hospitalLabel.text = [NSString stringWithFormat:@"%@ | %@",dataDic[@"hospital"],dataDic[@"department"]];
    self.contentLabel.text = LGNSString(dataDic[@"adeptat"]);
    [self.contentLabel lineSpacing:3];
}


#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.contentView.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.selectBtn];
    [self.baseView addSubview:self.headPic];
    [self.baseView addSubview:self.docNameLabel];
    [self.baseView addSubview:self.postTitleLabel];
    [self.baseView addSubview:self.hospitalLabel];
    [self.baseView addSubview:self.bottomView];
    [self.bottomView addSubview:self.iconView];
    [self.bottomView addSubview:self.contentLabel];
   
    [self.docNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headPic.mas_right).offset(viewPix(12));
        make.top.equalTo(self.headPic);
        make.height.equalTo(@(viewPix(22)));
    }];
    [self.postTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.docNameLabel.mas_right).offset(viewPix(6));
        make.centerY.equalTo(self.docNameLabel);
        make.width.equalTo(@(viewPix(70)));
        make.height.equalTo(@(viewPix(22)));
    }];
    [self.hospitalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.docNameLabel.mas_bottom).offset(viewPix(6));
        make.left.equalTo(self.docNameLabel);
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.height.equalTo(@(20));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(viewPix(7));
        make.top.equalTo(self.bottomView).offset(viewPix(8));
        make.right.equalTo(self.bottomView).offset(-viewPix(5));
    }];
}
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(16), viewPix(8), Screen_W-viewPix(32), viewPix(137))];
        [_baseView setShadoWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:15];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIButton *)selectBtn{
    if(!_selectBtn){
        _selectBtn = [UIButton buttonWithImage:@"unselect24" selectImage:@"selected24"];
        _selectBtn.frame = CGRectMake(0, viewPix(44), viewPix(48), viewPix(48));
    }
    return _selectBtn;
}

-(UIImageView *)headPic{
    if(!_headPic){
        _headPic = [[UIImageView alloc]initWithFrame:CGRectMake(viewPix(48), viewPix(12), viewPix(46), viewPix(46))];
        _headPic.backgroundColor = [UIColor colorWithString:@"#F7F9FB"];
        _headPic.cornerRidus = 5;
    }
    return _headPic;
}

-(UILabel *)docNameLabel{
    if(!_docNameLabel){
        _docNameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _docNameLabel;
}

-(UILabel *)postTitleLabel{
    if(!_postTitleLabel){
        _postTitleLabel = [UILabel lableWithText:@"" colorString:@"#56BEA0" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentCenter lines:1];
        _postTitleLabel.backgroundColor = [UIColor colorWithString:@"#EBF8F3"];
        _postTitleLabel.cornerRidus = viewPix(11);
    }
    return _postTitleLabel;
}

-(UILabel *)hospitalLabel{
    if(!_hospitalLabel){
        _hospitalLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _hospitalLabel;
}

-(UIView *)bottomView{
    if(!_bottomView){
        _bottomView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(48), viewPix(70), Screen_W-viewPix(92), viewPix(54))];
        _bottomView.backgroundColor = [UIColor colorWithString:@"#F7F9FB"];
    }
    return _bottomView;
}


-(UIImageView *)iconView{
    if(!_iconView){
        _iconView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"聊天咨询-推荐擅长"]];
        _iconView.frame = CGRectMake(viewPix(6), viewPix(9), viewPix(35), viewPix(15));
    }
    return _iconView;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _contentLabel;
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
